package com.example.demo.config;

import com.example.demo.intercepotor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName: AdminWebConfig
 * @Description:
 *  1. 编写一个拦截器实现HandlerInterceptor接口
 *  2. 拦截器注册到容器中（实现WebMvcConfiguree的addInterceptor）
 *  3. 指定拦截规则
 * @Author: 12071
 * @Date: 2021/4/11 15:33
 */
//@Configuration
public class AdminWebConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**") //拦截所有，包括静态资源
                .excludePathPatterns("/","/login","/css/**","/fonts/**","/images/**","/js/**");
    }
}
